import { request } from 'ice'; // 使用命名导入

export const productApi = {
  // 获取商品列表
  getList: (data: any) => {
    return request({
      method: "POST",
       data,
      url: "/products/list",
    });
  },
  // 复制商品
  copy: (data: any) => {
    return request({
      method: "POST",
      data,
      url: "/products/copy",
    });
  },

  // 创建商品
  create: (data: any) => {
    return request({
      method: "POST",
      data,
      url: "/products/create",
    });
  },

  // 更新商品
  update: (data: any) => {
    return request({
      method: "POST",
      data,
      url: "/products/update",
    });
  },

  // 删除商品
  delete: (id: string | number) => {
    return request({
      method: "POST",
      data: { id },
      url: "/products/delete",
    });
  },
};




// 品牌相关接口
export const brandApi = {
  getList: (data: any) => {
    return request({
      method: "POST",
      data,
      url: "/brand/list",
    });
  },
  create: (data: any) => {
    return request({
      method: "POST",
      data,
      url: "/brand/create",
    });
  },
  update: (data: any) => {
    return request({
      method: "POST",
      data,
      url: "/brand/update",
    });
  },
  delete: (id: string | number) => {
    return request({
      method: "POST",
      data: { id },
      url: "/brand/delete",
    });
  },
};

// 上传相关接口
export const uploadApi = {
  // 单文件上传
  single: (formData: FormData) => {
    return request({
      method: "POST",
      data: formData,
      url: "/upload/single",
    });
  },

  // 批量上传
  batch: (formData: FormData) => {
    return request({
      method: "POST",
      data: formData,
      url: "/upload/batch",
    });
  },
};

// 类型定义
export interface ProductListParams {
  page: number;
  pageSize: number;
  [key: string]: any;
}

export interface CategoryListParams {
  page: number;
  pageSize: number;
  [key: string]: any;
}

export interface BrandListParams {
  page: number;
  pageSize: number;
  categoryId?: string;
  [key: string]: any;
}

export interface ApiResponse<T> {
  success: boolean;
  data: T;
  message?: string;
}

// 其他接口请求可以在这里继续添加 